# import requests
# # get 请求中添加 headers
# # 最基本的get请求
# url = 'http://www.douban.com'
#
# # 也可以这样写
# # response = requests.request("GET", url)
#
# headers = {
#     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
# }
# response = requests.get(url, headers=headers)
# # 查看响应内容， response.text 返回的是Unicode格式的数据
# print(response.text)
#
# # 查看你响应内容，response.content 返回的是字节流数据
# print(response.content)
#
# # 查看完整URL地址
# print(response.url)
#
# # 查看响应头部字符编码
# print(response.encoding)
#
# # 查看响应码
# print(response.status_code)


# import requests
#
# # get请求中添加params
# url = 'https://www.baidu.com/s?'
#
# kw = {
#     'wd': '长城'
# }
#
# headers = {
#     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
# }
# response = requests.get(url, params=kw, headers=headers)
# response.encoding = 'utf-8'
# # 查看响应内容， response.text 返回的是Unicode格式的数据
# print(response.text)

# import requests
# post 请求
# url = 'https://httpbin.org/post'
#
# formdata = {
#     'name': '张三',
#     'address': '6666'
# }
# response = requests.post(url, data=formdata)
#
# # print(response.text) # 不是utf-8格式
# print(response.json())

# import requests
# # 代理 proxies参数
# # 根据协议类型，选择不同的代理
# proxies = {
#     'http': 'http://12.34.56.79:9527',
#     'https': 'http://12.34.56.79:9527',
# }
#
# response = requests.get('http://www.baidu.com', proxies=proxies)
#
# print(response.text)
#
# # 也可以通过本地环境变量 HTTP_PROXY 和 HTTPS_PROXY 来配置代理：
# # export HTTP_PROXY="http://12.34.56.79:9527"export HTTPS_PROXY="http://12.34.56.79:9527"

# 私密代理
# import requests
# # 如果代理需要使用 HTTP Basic Auth，可以使用下面格式
# proxy = {"http": "mr_mao_hacker:sffqry9r@61.158.163.13.L16816"}
#
# response = requests.get("http://www.baidu.com", proxies=proxy)
#
# print(response.text)

# # web客户端验证
# import requests
#
# auth = {'test', '123456'}
#
# response = requests.get('http://192.168.199.107', auth=auth)
# print(response.text)





# import requests
#
# response = requests.get('http://www.baidu.com/')
#
# # 返回CookieJar对象
# cookiejar = response.cookies
#
# # 将cookiejar 转为字典
# cookiedict = requests.utils.dict_from_cookiejar(cookiejar)
#
# print(cookiejar)
#
# print(cookiedict)


# import requests
#
# session = requests.session()
#
# session.post()
#
# session.get()

